//登录验证1
function blurInput() {
	//用户名
	let username = document.getElementById("username");
	//用户名错误提示
	let usernameTip = document.getElementById("usernameTip");
	//输入的值
	let usernameVal = document.getElementById("username").value;
	
	if (usernameVal.length < 1) {
		username.style.backgroundColor = '#fff0f0';
		username.style.border = '1px solid #d95c5c';
		username.style.borderLeft = '4px solid #d95c5c';
		username.style.marginTop = '10px';
		username.style.marginBottom = '10px';
		usernameTip.style.display = 'block';
	} else {
		username.style.border = '1px solid #ccc';
		username.style.backgroundColor = '#fff';
		usernameTip.style.display = 'none';
	}
}

function blurInput2() {
		let password = document.getElementById("password");
		password.style.border = '1px solid #ccc';
		password.style.backgroundColor = '#fff';
}

//注册验证
function onBlurInput() {
	//姓名
	let username = document.getElementById("username");
	
	//姓名的值
	let usernameVal = document.getElementById("username").value;
	let passwordVal = document.getElementById("password").value;
	
	//姓名提示
	let usernameTip1 = document.getElementById("usernameTip1");
	let usernameTip2 = document.getElementById("usernameTip2");
	
	//姓名校验
	if( usernameVal.length  < 1) {
		username.style.backgroundColor = '#fff0f0';
		username.style.border = '1px solid #d95c5c';
		username.style.borderLeft = '4px solid #d95c5c';
		username.style.marginTop = '10px';
		username.style.marginBottom = '10px';
		usernameTip1.style.display = 'block';
		usernameTip2.style.display = 'none';
	} else if ( usernameVal.length < 2 || usernameVal.length > 60) {
		username.style.backgroundColor = '#fff0f0';
		username.style.border = '1px solid #d95c5c';
		username.style.borderLeft = '4px solid #d95c5c';
		username.style.marginTop = '10px';
		username.style.marginBottom = '10px';
		usernameTip2.style.display = 'block';
		usernameTip1.style.display = 'none';
	} else {
		username.style.border = '1px solid #ccc';
		username.style.backgroundColor = '#fff';
		usernameTip1.style.display = 'none';
		usernameTip2.style.display = 'none';
	}
}

//手机号验证
function onBlurInput2() {
	//手机号
	let phone = document.getElementById("phone");
	
	//手机号的值
	let phoneVal = document.getElementById("phone").value;
	
	//手机号校验提示
	let phoneTip1 = document.getElementById("phoneTip1");
	let phoneTip2 = document.getElementById("phoneTip2");
	
	//手机号校验
	if( phoneVal.length  < 1) {
		console.log(phoneVal.length)
		phone.style.backgroundColor = '#fff0f0';
		phone.style.border = '1px solid #d95c5c';
		phone.style.borderLeft = '4px solid #d95c5c';
		phone.style.marginTop = '10px';
		phone.style.marginBottom = '10px';
		phoneTip1.style.display = 'block';
		phoneTip2.style.display = 'none';
	} else if ( phoneVal.length < 2 ||  phoneVal.length > 60) {
		phone.style.backgroundColor = '#fff0f0';
		phone.style.border = '1px solid #d95c5c';
		phone.style.borderLeft = '4px solid #d95c5c';
		phone.style.marginTop = '10px';
		phone.style.marginBottom = '10px';
		phoneTip2.style.display = 'block';
		phoneTip1.style.display = 'none';
	} else {
		phone.style.border = '1px solid #ccc';
		phone.style.backgroundColor = '#fff';
		phoneTip1.style.display = 'none';
		phoneTip2.style.display = 'none';
	}
}

//密码验证
function onBlurInput3() {
	//密码
	let password = document.getElementById("password");
	
	//密码的值
	let passwordVal = document.getElementById("password").value;
	
	//密码提示
	let passwordTip1 = document.getElementById("passwordTip1");
	let passwordTip2 = document.getElementById("passwordTip2");
	
	//密码校验
	if( passwordVal.length  < 1) {
		password.style.backgroundColor = '#fff0f0';
		password.style.border = '1px solid #d95c5c';
		password.style.borderLeft = '4px solid #d95c5c';
		password.style.marginTop = '10px';
		password.style.marginBottom = '10px';
		passwordTip1.style.display = 'block';
		passwordTip2.style.display = 'none';
	} else if ( passwordVal.length < 6 || passwordVal.length > 32) {
		password.style.backgroundColor = '#fff0f0';
		password.style.border = '1px solid #d95c5c';
		password.style.borderLeft = '4px solid #d95c5c';
		password.style.marginTop = '10px';
		password.style.marginBottom = '10px';
		passwordTip2.style.display = 'block';
		passwordTip1.style.display = 'none';
	} else {
		password.style.border = '1px solid #ccc';
		password.style.backgroundColor = '#fff';
		passwordTip1.style.display = 'none';
		passwordTip2.style.display = 'none';
	}
}

//注册
//输入框焦点改变输入框颜色
function onFocusInput1() {
	let username = document.getElementById("username");
	username.style.border = '1px solid #fe7300';
}

function onFocusInput2() {
	let phone = document.getElementById("phone");
	phone.style.border = '1px solid #fe7300';
}

function onFocusInput3() {
	let password = document.getElementById("password");
	password.style.border = '1px solid #fe7300';
}

//登录
//输入框焦点改变输入框颜色
function focusInput1() {
	let username = document.getElementById("username");
	username.style.border = '1px solid #fe7300';
}

function focusInput2() {
	let password = document.getElementById("password");
	password.style.border = '1px solid #fe7300';
}

function toLogin() {
	let username = document.getElementById("username").value;
	let password = document.getElementById("password").value;
	console.log(username + ',' + password)
	if(username.length >= 2 && username.length <= 60 && password.length >= 6) {
		alert("登录成功！");
	} else {
		alert("用户名或密码错误！");
	}
}

function toRegister() {
	let username = document.getElementById("username").value;
	let phone = document.getElementById("phone").value;
	let password = document.getElementById("password").value;
	console.log(username + ',' + password)
	if(username.length >= 2 && username.length <= 60 && phone.length >= 2 && phone.length <= 60 && password.length >= 6) {
		alert("注册成功！");
	} else {
		alert("注册失败！");
	}
}